﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EDM
{
    public class Roletranslator
    {
       
        //To Translate AuthorityLevelDataEntity to AuthorityLevelBusinessEntity
        public static BLL.Role TranslatetoRoleBE(EDM.Role roleDE)
        {
            BLL.Role roleBE = new BLL.Role();
            roleBE.RoleId = roleDE.RoleId;
            roleBE.RoleName = roleDE.RoleName;
            roleBE.StatusId =(BLL.RoleStatus)roleDE.StatusId;
            List<BLL.Authority> list = new List<BLL.Authority>();
            foreach (EDM.RoleAuthority item in roleDE.RoleAuthorities.ToList<EDM.RoleAuthority>())
            {
                BLL.Authority  authority= Authoritytranslator.TranslatetoAuthorityBE(item.Authority);
                list.Add(authority);

            }
            roleBE.Authorities = list;
            return roleBE;
        }

        //To Translate AuthorityBusinessEntity to AuthorityDataEntity
        public static EDM.Role TranslatetoRoleDE(BLL.Role roleBE)
        {
            EDM.Role roleDE = new EDM.Role();
        
            roleDE.RoleId = roleBE.RoleId;
            roleDE.RoleName = roleBE.RoleName;
            roleDE.StatusId = (int)roleBE.StatusId;

           

            return roleDE;
        }
    }
}
